import os
import gradio as gr
from dotenv import load_dotenv
from tabs.scenario_tab import create_scenario_tab
from tabs.conversation_tab import create_conversation_tab
from tabs.vocab_tab import create_vocab_tab
from utils.logger import LOG

# 加载环境变量
load_dotenv()

def main():
    with gr.Blocks(title="AI英语私教 LinguaBot") as language_mentor_app:
        create_scenario_tab()
        create_conversation_tab()
        create_vocab_tab()

    # 从环境变量获取配置
    host = os.getenv("APP_HOST", "0.0.0.0")
    port = int(os.getenv("APP_PORT", "7860"))
    share = os.getenv("APP_SHARE", "true").lower() == "true"

    LOG.info(f"启动 AI英语私教 LinguaBot 应用，地址: {host}:{port}, 分享: {share}")

    # 启动应用
    language_mentor_app.launch(
        share=share,
        server_name=host,
        server_port=port
    )

if __name__ == "__main__":
    main()
